﻿using Sandbox.ModAPI;
using VRage.Game.Components;

namespace Vicizlat.MultifloorCargoElevator
{
    [MySessionComponentDescriptor(MyUpdateOrder.BeforeSimulation)]
    public class CargoElevatorSession : MySessionComponentBase
    {
        public static bool _init;

        public override void UpdateBeforeSimulation()
        {
            base.UpdateBeforeSimulation();
            if (MyAPIGateway.Session == null) return;
            if (!_init)
            {
                Logging.Instance.WriteLine("<<< Debug Log Started >>>");
                Communication.RegisterHandlers();
                _init = true;
            }
        }

        protected override void UnloadData()
        {
            Communication.UnregisterHandlers();
            Logging.Instance.WriteLine("<<< Debug Log Closed >>>");
            Logging.Instance.Close();
        }
    }
}